@extends('admin.admin')

@section('content')
        <!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        管理员权限
        <small>列表</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="/admin"><i class="fa fa-dashboard"></i> 控制面板</a></li>
        <li><a href="#"><i class="fa fa-dashboard"></i> 管理员设置</a></li>
        <li class="active">管理员权限</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="row">
        <div class="col-xs-12">
            <div class="box box-primary">
                <div class="box-header">
                    <h3 class="box-title">管理员权限</h3>
                    <div class="box-tools">
                        <a href="{{route('admin.admin_action.create')}}" type="button" class="btn btn-block btn-success btn-xs"><i class="icon  glyphicon glyphicon-plus"></i> 添加</a>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body table-responsive no-padding">
                    {!! Form::open(['route'=>'admin.admin_action.sort','name'=>'list_order'])  !!}
                    <table class="table table-hover">
                        <tr>
                            <th  style="width: 50px;">排序</th>
                            <th  style="width: 200px;">名称</th>
                            <th>描述</th>
                            <th  style="width: 80px;">是否显示</th>
                            <th style="width: 180px;">操作</th>
                        </tr>
                        @foreach ($adminAction as $action)
                            <tr>
                                <td>{!! Form::text('list_order['.$action->id.']',intval($action->list_order),['style'=>'width:40px; text-align:center']) !!}</td>

                                <td>
                                        <?php if ($action->hasChildren()){?>
                                        <i style="padding-left: {{($action->deepth)*20}}px" class="icon "></i>├
                                         <?php }else{?>
                                        <i style="padding-left: {{($action->deepth)*20}}px" class="icon "></i>└
                                        <?php }?>&nbsp;{{$action->name}}
                                </td>
                                <td>{{$action->description}}</td>

                                <td>{{$action->is_show}}</td>
                                <td>
                                    <a href="{{Route('admin.admin_action.create',['id'=>$action->id])}}" type="button" class="btn  btn-success btn-xs"><i class="icon  glyphicon glyphicon-plus"></i> 添加</a>
                                    <a href="{{Route('admin.admin_action.edit',$action->id)}}" type="button" class="btn  btn-default btn-xs"><i class="icon  glyphicon glyphicon-edit"></i> 修改</a>
                                    <button type="button" class="btn  btn-danger btn-xs"  data-toggle="modal" data-target="#modal{{$action->id}}"><i class="icon  glyphicon glyphicon-remove"></i> 删除</button>
                                    <div id="modal{{$action->id}}" class="modal fade">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                    <h4 class="modal-title">删除警告:</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <p>确认要删除管理员[{{$action->name}}]吗?</p>
                                                </div>
                                                <div class="modal-footer">
                                                    {!! Form::open(['route' => ['admin.admin_action.destroy', $action->id],'name'=>$action->id]) !!}
                                                    {!! Form::hidden('_method', 'DELETE') !!}
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                    <button type="submit" class="btn btn-danger">删除</button>
                                                    {!!Form::close()   !!}
                                                </div>
                                            </div><!-- /.modal-content -->
                                        </div><!-- /.modal-dialog -->
                                    </div><!-- /.modal -->
                                </td>
                            </tr>
                        @endforeach
                            <tfoot>
                                <td>
                                    <button type="submit" class="btn  btn-success btn-xs"> 排序</button>

                                </td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tfoot>
                    </table>
                    {!! Form::hidden('_method', 'PUT') !!}

                    {!! Form::close()  !!}

                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
    </div>



</section>
<!-- /.content -->

<script>
    $('.btn-danger').on('click',function(){
        console.log('11');
    });
</script>
@endsection